package com.csi.service.impl;

import com.csi.domain.UserAssess;
import com.csi.mapper.AssessMapper;
import com.csi.mapper.UserBookMapper;
import com.csi.service.AssessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class AssessServiceImpl implements AssessService {
    @Autowired
    private AssessMapper assessMapper;

    @Autowired
    private UserBookMapper userBookMapper;

    @Override
    public int save(UserAssess userAssess) {
        int updated = userBookMapper.updateBook4Access(userAssess.getDueId());
        int saved = assessMapper.save(userAssess);
        return updated + saved;
    }

    @Override
    public Map<String, Object> findById(long userId) {
        return assessMapper.findById(userId);
    }

    @Override
    public Map<String, Object> findByPackageId(long packageId) {
        return assessMapper.findByPackageId(packageId);
    }
}
